package com.quwan.manager.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.quwan.common.result.PageResult;
import com.quwan.manager.controller.dto.DynamicCommentDto;
import com.quwan.manager.service.DynamicCommentService;
import com.quwan.mapper.TDynamicCommentMapper;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * @author laozhang
 * @date 2022/1/13 15:01
 */
@Service
@RequiredArgsConstructor
public class DynamicCommentServiceImpl implements DynamicCommentService {
    private final TDynamicCommentMapper dynamicCommentMapper;

    @Override
    public PageResult<DynamicCommentDto> getDynamicCommentListPage(int page, int size, String dynamicId, String mId, String memberName, String content, String beginTime, String endTime) {
        Page<DynamicCommentDto> dynamicCommentPage = dynamicCommentMapper.selectManageDynamicCommentList(new Page<>(page, size),dynamicId, mId, memberName,content,beginTime,endTime);
        PageResult<DynamicCommentDto> result = new PageResult<DynamicCommentDto>()
                .setCurrent(dynamicCommentPage.getCurrent())
                .setPages(dynamicCommentPage.getPages())
                .setSize(dynamicCommentPage.getSize())
                .setTotal(dynamicCommentPage.getTotal())
                .setRecords(dynamicCommentPage.getRecords());
        return result;
    }

    @Override
    public boolean delDynamicComment(Integer id) {
        return dynamicCommentMapper.deleteById(id) == 1;
    }

}
